package com.ccdt.tv.smartrecommend.presenter.MainActivity;

import android.util.Log;

import com.blankj.utilcode.util.Utils;
import com.ccdt.tv.smartrecommend.model.bean.RecordBean;
import com.ccdt.tv.smartrecommend.utils.GetTokenServiceHelper;
import com.ccdt.tv.smartrecommend.utils.RecordDBUtil;

import java.util.List;

/**
 * Created by syt on 2018/9/10.
 * 主页面 MVP P层
 * 主要用于测试
 */

public class MainActivityPresenter extends MainActivityContract.Presenter implements GetTokenServiceHelper.OnCaCardChanged, GetTokenServiceHelper.ServiceConnectListener {
    private static final String TAG="MainPresenter";

    @Override
    public void doBindExtraService() {
        //CA卡绑定服务
        GetTokenServiceHelper.getInstance().bind(Utils.getApp());
        GetTokenServiceHelper.getInstance().setOnCaCardChanged(this);
        GetTokenServiceHelper.getInstance().setServiceConnectListener(this);
        RecordDBUtil recordUtil = RecordDBUtil.getInstance(Utils.getApp());
//        for(int i = 0;i<=20;i++){
//            RecordBean bean = new RecordBean((long)i,"测试"+i,"vod","yp","voole：xxx","www.baidu.com");
//            recordUtil.insert(bean);
//        }
    }

    @Override
    public void getRecordList() {

    }

    @Override
    public void onCaCardChanged() {
        //CA卡更换回调
    }

    @Override
    public void doUnBindExtraService() {
        Log.i(TAG,"doUnBindExtraService");
        GetTokenServiceHelper.getInstance().unBind(Utils.getApp());
    }

    @Override
    public void onConnected() {
        //服务链接成功
        RecordDBUtil recordUtil = RecordDBUtil.getInstance(Utils.getApp());
        List<RecordBean> list = recordUtil.listAll();
//        for (RecordBean bean : list){
//            Log.w(TAG, "onConnected: " +bean.toString());
//        }
    }
}
